home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Peter Lewis / Talk 1.0.6 / Talk ƒ / StatusLDEF.p < prev    next >
Encoding:
Text File  |  1992-04-20  |  2.4 KB  |  102 lines  |  [TEXT/PJMM]

  1. unit StatusLDEF;
  2.  
  3. { This program was written by Peter N Lewis, Mar 1992 in THINK Pascal 4.0.1 }
  4.  
  5. interface
  6.  
  7.     procedure Main (message: integer; select: boolean; var r: Rect; c: Cell; dataOffset, dataLen: integer; lh: ListHandle);
  8.  
  9. implementation
  10.  
  11.     uses
  12.         LDEFTypes;
  13.  
  14.     const
  15.         sicn1_offset = 2;
  16.         sicn2_offset = 20;
  17.         str_offset = 38;
  18.  
  19.     procedure Main (message: integer; select: boolean; var r: Rect; c: Cell; dataOffset, dataLen: integer; lh: ListHandle);
  20.         procedure DoInit;
  21.             var
  22.                 fi: FontInfo;
  23.         begin
  24.             GetFontInfo(fi);
  25.             lh^^.cellsize.v := 18;
  26.             lh^^.indent.v := fi.ascent + 1;
  27.             lh^^.indent.h := 4;
  28.         end;
  29.  
  30.         procedure DoClose;
  31.         begin
  32.         end;
  33.  
  34.         procedure DoDraw;
  35.             var
  36.                 where: point;
  37.             procedure PlotSICN (id, index: integer; offset: integer);
  38.                 var
  39.                     iconH: handle;
  40.                     iconMap: bitmap;
  41.                     iconRect: rect;
  42.             begin
  43.                 iconH := GetResource('SICN', id);
  44.                 if iconH <> nil then begin
  45.                     HLock(iconH);
  46.                     iconMap.baseAddr := ptr(ord(iconH^) + (index - 1) * 32);
  47.                     iconMap.rowBytes := 2;
  48.                     SetRect(iconmap.bounds, 0, 0, 16, 16);
  49.                     iconRect.left := r.left + offset;
  50.                     iconRect.top := r.top + 1;
  51.                     iconRect.right := iconRect.left + 16;
  52.                     iconRect.bottom := iconRect.top + 16;
  53.                     CopyBits(iconmap, lh^^.port^.portbits, iconmap.bounds, iconRect, srcCopy, nil);
  54.                     HUnlock(iconH);
  55.                     HPurge(iconH);
  56.                 end
  57.             end;
  58.             var
  59.                 celldata: cellRecord;
  60.                 s: str255;
  61.                 sw: integer;
  62.         begin
  63.             if datalen > SizeOf(celldata) - SizeOf(celldata.str2) then begin
  64.                 where.h := r.left + lh^^.indent.h;
  65.                 where.v := r.top + lh^^.indent.v;
  66.                 PenNormal;
  67.                 if datalen > SizeOf(celldata) then
  68.                     datalen := SizeOf(celldata);
  69.                 BlockMove(ptr(longInt(lh^^.cells^) + dataoffset), @celldata, datalen);
  70.                 EraseRect(r);
  71.                 PlotSICN(celldata.sicn1id, celldata.sicn1index, sicn1_offset);
  72.                 PlotSICN(celldata.sicn2id, celldata.sicn2index, sicn2_offset);
  73.                 IUTimeString(longInt(60) * 60 * 24 - 60, false, s);
  74.                 sw := StringWidth(s);
  75.                 MoveTo(where.h + str_offset + sw - StringWidth(celldata.str1), where.v);
  76.                 DrawString(celldata.str1);
  77.                 MoveTo(where.h + str_offset + sw + 2, where.v);
  78.                 DrawString(celldata.str2);
  79.             end;
  80.             if select then
  81.                 InvertRect(r);
  82.         end;
  83.  
  84.         procedure DoHilite;
  85.         begin
  86.             InvertRect(r);
  87.         end;
  88.  
  89.     begin
  90.         case message of
  91.             lInitMsg: 
  92.                 DoInit;
  93.             lDrawMsg: 
  94.                 DoDraw;
  95.             lHiliteMsg: 
  96.                 DoHilite;
  97.             lCloseMsg: 
  98.                 DoClose;
  99.         end;
  100.     end;
  101.  
  102. end.